package com.wintrisstech.iaroc.sunspot;

import java.io.IOException;

import com.sun.spot.sensorboard.EDemoBoard;
import com.sun.spot.sensorboard.peripheral.LEDColor;
import com.wintrisstech.iaroc.irobot.IRobotCreateExtendedInterface;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * The startApp method of this class is called by the VM to start the
 * application.
 */
public class MidletTemplate extends MIDlet {

    protected void startApp() throws MIDletStateChangeException {
        try {
            XLights lights = new XLights(EDemoBoard.getInstance(), 0, 7);
            lights.setColor(LEDColor.YELLOW);
            lights.startPsilon();
            try {
                IRobotCreateExtendedInterface create = new IRobotCreateExtendedInterface();
                lights.setColor(LEDColor.GREEN);
                create.setVelocity(100);
                create.goForward();
                create.waitTimeMilliseconds(500);
                create.driveStop();
                lights.setColor(LEDColor.BLUE);
            } catch (IllegalStateException e) {
                lights.setColor(LEDColor.RED);
                e.printStackTrace();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    }
    
}
